<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui" xmlns:oso="http://osoftware.com/facelets" template="/WEB-INF/templates/mainEditLayout.xhtml">

	<ui:define name="title">
			#{resourceBundle['attentionTime.title']}
	</ui:define>

	<ui:define name="editFields">
		<p:wizard widgetVar="attentionTimeWizard" flowListener="#{attentionTimeController.onFlowProcess}" backLabel="#{resourceBundle['wizard.back']}" nextLabel="#{resourceBundle['wizard.next']}">

			<p:tab id="attentionTimeData" title="1. Turno">
				<h:panelGrid id="switcher" columns="3">
					<oso:selectOneMenu id="periodSwitcher" label="Tipo de Turno" value="#{attentionTimeModel.periodModel.attentionTimePeriodType}" converter="attentionTimePeriodTypeConverter"
						items="#{attentionTimeModel.periodModel.attentionTimePeriodTypes}" itemLabel="name">
						<f:ajax render="@form" />
					</oso:selectOneMenu>
				</h:panelGrid>
				<h:panelGrid columns="3" id="uniqueFields" widgetVar="uniqueFieldsVar" rendered="#{attentionTimeModel.periodModel.attentionTimePeriodType == 'UNIQUE'}">
					<oso:calendar id="timeAndDate" label="#{resourceBundle['attentionTime.timeAndDate']}" value="#{attentionTimeModel.timeAndDate}" required="true" includeTime="true" />
				</h:panelGrid>

				<h:panelGrid columns="3" id="periodicFields" widgetVar="periodicFieldsVar" rendered="#{attentionTimeModel.periodModel.attentionTimePeriodType == 'PERIODICAL'}">
					<oso:calendar id="startDate" label="#{resourceBundle['attentionTime.period.startDate']}" value="#{attentionTimeModel.periodModel.startDate}" />

					<oso:calendar id="endDate" label="#{resourceBundle['attentionTime.period.endDate']}" value="#{attentionTimeModel.periodModel.endDate}">
					</oso:calendar>

					<oso:inputText id="hour" type="number" label="#{resourceBundle['attentionTime.period.hour']}" value="#{attentionTimeModel.periodModel.hour}" size="2">
						<f:validateLongRange minimum="0" maximum="23" />
					</oso:inputText>

					<oso:inputText id="minutes" type="number" label="#{resourceBundle['attentionTime.period.minutes']}" value="#{attentionTimeModel.periodModel.minute}" size="2">
						<f:validateLongRange minimum="0" maximum="59" />
					</oso:inputText>

					<p:outputLabel value="#{resourceBundle['attentionTime.period.days']}:" for="days" rendered="true" style="float:right;" />
					<p:selectManyButton value="#{attentionTimeModel.periodModel.days}" id="days">

						<f:selectItems value="#{attentionTimeController.daysOfWeek}" var="day" itemLabel="#{day.dayName}" itemValue="#{day.order}" />
					</p:selectManyButton>
					<h:outputText value="" />

				</h:panelGrid>
			</p:tab>
			<p:tab id="patientData" title="2. Paciente">
				<h:panelGrid columns="3">
					<oso:selectOneMenu id="patient" label="#{resourceBundle['attentionTime.patient']}" value="#{attentionTimeModel.patient}" converter="patientConverter"
						items="#{attentionTimeModel.selectablePatients}" itemLabel="fullName" required="true">
					</oso:selectOneMenu>
					<p:commandButton action="newPatient" value="Nuevo Paciente" process="@this" />
					<h:outputText value="" />
				</h:panelGrid>
			</p:tab>
			<p:tab id="specialistData" title="3. Especialista">
				<p:panelGrid columns="3">
					<oso:selectOneMenu id="specialist" label="#{resourceBundle['schedule.specialist']}" value="#{attentionTimeModel.specialist}" converter="specialistConverter"
						items="#{attentionTimeModel.selectableSpecialists}" itemLabel="fullName">
						<p:ajax event="change" update="specialistFee" />
					</oso:selectOneMenu>
					<oso:selectOneMenu id="specialistFee" label="#{resourceBundle['attentionTime.specialistFee']}" value="#{attentionTimeModel.specialistFee}" converter="specialistFeeConverter"
						items="#{attentionTimeModel.specialist.fees}" itemLabel="description">
						<p:ajax event="change" listener="#{attentionTimeController.onSpecialistFeeChange}" update="fee" />
					</oso:selectOneMenu>
					<oso:inputText type="number" id="fee" label="#{resourceBundle['attentionTime.fee']}" value="#{attentionTimeModel.fee}"/>
				</p:panelGrid>
			</p:tab>
			<p:tab id="finishData" title="3. Finalizar" rendered="false">
				<p:commandButton action="newPayment" value="Guardar y Pagar" process="@this" />
			</p:tab>
			<p:tab id="paymentData" title="3. Pago" rendered="false">
				<h:panelGrid columns="1">
					<oso:selectOneMenu id="paymentType" label="#{resourceBundle['attentionTime.paymentType']}" value="#{attentionTimeModel.paymentType}" converter="paymentTypeConverter"
						items="#{attentionTimeModel.selectablePaymentTypes}" itemLabel="name" required="true" />
				</h:panelGrid>
			</p:tab>
			<p:tab id="cashPaymentData" title="3.1 Efectivo" rendered="false">
				<h:panelGrid columns="1">

				</h:panelGrid>
			</p:tab>
			<p:tab id="prepaidPaymentData" title="3.2 Obra Social" rendered="false">
				<oso:selectOneMenu id="patientPrepaid" label="#{resourceBundle['attentionTime.patientPrepaid']}" value="#{attentionTimeModel.patientPrepaid}" converter="patientPrepaidConverter"
					items="#{attentionTimeModel.specialist.prepaids}" itemLabel="description" required="true">
				</oso:selectOneMenu>
			</p:tab>
		</p:wizard>
		<h:outputText value="" />
		<h:outputText value="" />
	</ui:define>

</ui:composition>